<form action="{:url()}" method="post" class="form_single">
  <div class="box">
    <div class="box-header with-border">
      <h3 class="box-title">批量调价</h3>
    </div>
    <div class="box-body">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label>调价方式</label>
            <span>（选择调价的方式）</span>
            <select class="form-control" name="adjust_type" id="adjust_type">
              <option value="1">按金额调整</option>
              <option value="2">按百分比调整</option>
              <option value="3">设置固定价格</option>
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label>调整值</label>
            <span>（调价的具体数值）</span>
            <input class="form-control" name="adjust_value" placeholder="请输入调整值" value="" type="number" step="0.01">
          </div>
        </div>

        <div class="col-md-6">
          <div class="form-group">
            <label>调价方向</label>
            <span>（价格调整方向）</span>
            <select class="form-control" name="adjust_direction" id="adjust_direction">
              <option value="1">上调</option>
              <option value="2">下调</option>
            </select>
          </div>
        </div>

        <div class="col-md-6">
          <div class="form-group">
            <label>生效时间</label>
            <span>（调价生效的时间）</span>
            <input class="form-control" name="effective_time" placeholder="请选择生效时间" value="" type="datetime-local">
          </div>
        </div>

        <div class="col-md-12">
          <div class="form-group">
            <label>选择产品</label>
            <span>（选择要调价的产品）</span>
            <div class="checkbox-group" style="max-height: 200px; overflow-y: auto; border: 1px solid #ddd; padding: 10px;">
              <label class="checkbox-inline">
                <input type="checkbox" id="select_all"> 全选
              </label>
              <hr>
              {volist name="products" id="product"}
              <label class="checkbox-inline" style="display: block; margin-bottom: 5px;">
                <input type="checkbox" name="product_ids[]" value="{$product.id}"> 
                {$product.name} (当前价格: ￥{$product.current_price|default='0.00'})
              </label>
              {/volist}
            </div>
          </div>
        </div>

        <div class="col-md-12">
          <div class="form-group">
            <label>调价说明</label>
            <span>（本次调价的说明）</span>
            <textarea class="form-control" name="remark" rows="3" placeholder="请输入调价说明"></textarea>
          </div>
        </div>
          
      </div>
    </div>
    <div class="box-footer">
      <button type="submit" class="btn btn-primary">确认调价</button>
      <button type="button" class="btn btn-default" onclick="layer.closeAll();">取消</button>
    </div>
  </div>
</form>

<script>
$(function() {
    // 全选功能
    $('#select_all').change(function() {
        $('input[name="product_ids[]"]').prop('checked', this.checked);
    });
    
    // 调价方式变化时的处理
    $('#adjust_type').change(function() {
        var type = $(this).val();
        var $direction = $('#adjust_direction');
        var $value = $('input[name="adjust_value"]');
        
        if (type == '3') { // 设置固定价格
            $direction.closest('.form-group').hide();
            $value.attr('placeholder', '请输入固定价格');
        } else {
            $direction.closest('.form-group').show();
            if (type == '1') { // 按金额调整
                $value.attr('placeholder', '请输入调整金额');
            } else { // 按百分比调整
                $value.attr('placeholder', '请输入调整百分比');
            }
        }
    });
    
    // 初始化
    $('#adjust_type').trigger('change');
});
</script>